package main

/*
  by zy
  部分内部类型定义

  - 2025.11.30

*/

type SubCmd int

const ( //子命令
  SubUnknown SubCmd = iota
  SubList
  SubUpload
  SubDownload
  SubDelete
  SubSet
  SubCheck
)

const ( //退出码
  ExitSuccess = 0
  ExitUsageError = 1
  ExitIoError = 2
  ExitFileError = 3 
  ExitMarshalError = 4
  ExitUnmarshalError = 5
  ExitRequestError = 6
  ExitOtherError = 7
)

const DefaultExpirationWindow = 14 // 证书过期窗口

type CLI struct { // 解析后的命令行参数
  AccessKey string            // Required
  SecretKey string            // Required
  SubCmd    SubCmd            // sub-commands：-list/-upload/-download/-delete/-set/-check
  CertFile  string            // Required: upload, Optional: download
  KeyFile   string            // Required: upload, Optional: download
  CertName  string            // Required: upload
  CN        string            // Required: upload
  CertID    string            // Required: delete/download/set
  Deploy    bool              // Optional: upload
  Verbose   bool              // Optional
  Expired   bool              // Optional: delete
  CertStr   string            // Contents of CertFile
  KeyStr    string            // Contents of KeyFile
  Fqdn      string            // Required: check/set/-upload with -deploy
  Days      int               // Optional: check
}

func (c SubCmd) String() string {
  switch (c) {
  case SubList: return "list"
  case SubUpload: return "upload"
  case SubDownload: return "download"
  case SubDelete: return "delete"
  case SubSet: return "set"
  case SubCheck: return "check"
  default: return "unknownCommand"
  }
}
